/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dyploma;
import java.io.File; 
import java.io.IOException;
import java.util.Date; 
import jxl.*;
import jxl.write.*;
import jxl.read.biff.BiffException;
/**
 *
 * @author Администратор
 */
public class Dyploma {
    
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException, BiffException, WriteException {
        double t=0;
        double pi = 3.14;
        double T1, T2, T=293;
        double Te=293;
        double I = 0.1;
        double R = 0.7;
        double h1=20.0, h2=30.0, h = 47.5;
        double r = 0.000005;
        double l = 0.001;
        double S = 2*3.14*r*l;
        double c = 132;
        double p = 19300;
        double p_res=0.000000055;
        double f = 5;
        double w = 2*pi*f;
        double q0;
        double freq=1;
        double phi, phi1, phi2;
        double H;
        q0=I*I*p_res*l/(2*pi*pi*r*r*r*r);
        WritableWorkbook workbook = Workbook.createWorkbook(new File("output.xls"));
        WritableSheet sheet = workbook.createSheet("First Sheet", 0);
        
         Label label = new Label(0, 1, "Dyploma"); 
         sheet.addCell(label); 
         jxl.write.Number time;
         jxl.write.Number temperature;
         jxl.write.Number heat;
//         jxl.write.Number temperature1;
//         jxl.write.Number temperature2;
//         jxl.write.Number phase;
//         jxl.write.Number phase1;
//         jxl.write.Number phase2;
//         jxl.write.Number temp;
//         jxl.write.Number temp1;
//         jxl.write.Number temp2;
         for (int i=0; i<6000; i++, t+=0.001){
             //temperature = new jxl.write.Number(1, i+2, T);
             time = new jxl.write.Number(0, i+2, t);
             //T=(T-(I*I*Math.sin(w*t)*Math.sin(w*t)*R/(h*S))-Te)*Math.exp(-(2*h/(c*p*r))*t)+I*I*Math.sin(w*t)*Math.sin(w*t)*R/(h*S)+Te;
             H = (I*I*p_res*l/(2*pi*r*r))*(1-Math.sin(2*w*t-pi/2))*300*t;
             T = -Math.exp(-(2*h/(c*p*r))*t)+q0*r/(2*h)+(q0*r/(2*Math.sqrt(h*h+p*c*w*r*p*c*w*r)))*Math.sin(2*w*t-pi/2-Math.atan(-p*c*w*r/h));
             
//             T1 = -Math.exp(-(2*h1/(c*p*r))*t)+q0*r/(2*h1)+(q0*r/(2*Math.sqrt(h1*h1+p*c*w*r*p*c*w*r)))*Math.sin(2*w*t-pi/2-Math.atan(-p*c*w*r/h1));
//             T2 = -Math.exp(-(2*h2/(c*p*r))*t)+q0*r/(2*h2)+(q0*r/(2*Math.sqrt(h2*h2+p*c*w*r*p*c*w*r)))*Math.sin(2*w*t-pi/2-Math.atan(-p*c*w*r/h2));

             temperature = new jxl.write.Number(1, i+2, T);
             heat = new jxl.write.Number(2, i+2, H);
//             temperature1 = new jxl.write.Number(2, i+2, T1);
//             temperature2 = new jxl.write.Number(3, i+2, T2);
             time = new jxl.write.Number(0, i+2, t);
             
             sheet.addCell(temperature);
             sheet.addCell(heat);
//             sheet.addCell(temperature1);
//             sheet.addCell(temperature2);
             sheet.addCell(time);
             
         }
//         for (int i=0; i<100; i++, freq++){
//         phi = -Math.atan(-p*c*2*pi*freq*r/h);
//         phi1 = -Math.atan(-p*c*2*pi*freq*r/h1);
//         phi2 = -Math.atan(-p*c*2*pi*freq*r/h2);
//         phase = new jxl.write.Number(4, i+2, phi);
//         phase1 = new jxl.write.Number(5, i+2, phi1);
//         phase2 = new jxl.write.Number(6, i+2, phi2);
//         sheet.addCell(phase);
//         sheet.addCell(phase1);
//         sheet.addCell(phase2);
//         }
//            double exp = (q0*r/(2*Math.sqrt(h*h+p*c*w*r*p*c*w*r)));
//            double exp1 = (q0*r/(2*Math.sqrt(h1*h1+p*c*w*r*p*c*w*r)));
//            double exp2 = (q0*r/(2*Math.sqrt(h2*h2+p*c*w*r*p*c*w*r)));
//             temp = new jxl.write.Number(7, 2, exp);
//             temp1 = new jxl.write.Number(7, 3, exp1);
//             temp2 = new jxl.write.Number(7, 4, exp2);
//             sheet.addCell(temp);
//             sheet.addCell(temp1);
//             sheet.addCell(temp2);
//         
         workbook.write(); 
         workbook.close();
    }
}
